package com.postracker.postracker;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import com.postracker.postracker.dao.UserDao;
import com.postracker.postracker.dao.impl.UserDaoImpl;
import com.postracker.postracker.dao.util.HibernateUtil;
import com.postracker.postracker.db.DataBase;
import com.postracker.postracker.db.DataBaseFactory;
import com.postracker.postracker.db.init.InitialData;
import com.postracker.postracker.model.User;

public class App {

	private static DataBase db;

	public static void main(String[] args) throws SQLException, IOException {
		db = DataBaseFactory.createNewSqliteDB();
		InitialData initialData = new InitialData(db);
		initialData.loadData();
		UserDao userDao = new UserDaoImpl(HibernateUtil.getSessionFactory()
				.openSession());
		List<User> users = userDao.findAll();
		for (User user : users) {
			System.out.println(user);
		}
	}

}
